home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
morse
/
dspmorse
/
morse.dsk
(
.txt
)
< prev
next >
Wrap
Turbo C Context File
|
1994-01-17
|
25KB
|
828 lines
Turbo C Context File
MORSE.C
VID.C
*.CPP
C:\CWORK\MORSE\SB.C
C:\CWORK\MORSE\MORSE.C
C:\CWORK\MORSE\MORSE.H
\ for (c=41; c<GRAPHTOP; c++)
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,l160+(c<<1),0xFA);
if (VIDSEG==0xB800)
pokeb(VIDSEG,l160+(c<<1)+1,col);
void wputc(char c, char move)
static int x=1, y=1;
pokeb(VIDSEG,(x<<1)+(y*160), c);
if (move)
x++;
if (x>=35)
y++;
if (y>=24)
y=1;
for (x=1; x<35; x++)
{
pokeb(VIDSEG,(x<<1)+(y*160),' ');
}
x=1;
void clrGraph(void)
int l, c, col, l160;
for (l=0,l160=0; l<(N-1); l++,l160+=160)
for (c=41; c<GRAPHTOP; c++)
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,l160+(c<<1),0xFA);
if (VIDSEG==0xB800)
pokeb(VIDSEG,l160+(c<<1)+1,col);
/////////////////////////////////////////////////////////////////////////////
// Display CT-VOICE.DRV version.
_BX = 0;
(*driver)();
ver = _AX;
printf("\nCT-VOICE.DRV version %d.%d.", (ver>>8)&0xFF, ver&0xFF);
void clrGraph(void)
int l, c, col, l160;
for (l=0,l160=0; l<(N-1); l++,l160+=160)
for (c=41; c<GRAPHTOP; c++)
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,l160+(c<<1),0xFA);
pokeb(VIDSEG,l160+(c<<1)+1,col);
int l, c, col, l160;
sbOpen();
printf("\nSetStat: %d", sbSetStatWord(&sbstat));
printf("\nRecSrc : %d", sbSetRecSrc(3)); // line in
printf("\nRecMode: %d", sbSetRecMode(0)); // mono
printf("\nSpkOnOf: %d", sbSpeaker(1)); // turn on speaker
// Set up the Sound Blaster, and
// display (although briefly) some
// interesting information about it.
sbOpen();
printf("\nSetStat: %d", sbSetStatWord(&sbstat));
printf("\nRecSrc : %d", sbSetRecSrc(3)); // line in
printf("\nRecMode: %d", sbSetRecMode(0)); // mono
printf("\nSpkOnOf: %d", sbSpeaker(1)); // turn on speaker
bufone = (char far *)farmalloc(SAMPLELEN+0x40);
buftwo = (char far *)farmalloc(SAMPLELEN+0x40);
if ((bufone==NULL) || (buftwo==NULL))
puts("Woops! No room for buffers!");
goto quickdone;
bufone = MK_FP(FP_SEG(bufone)+1,0);
buftwo = MK_FP(FP_SEG(buftwo)+1,0);
#define KCHECK 64 /* ratio of key pressed checks versus FFT cycles */
#define SCHECK 16 /* ratio of sampling rate checks versus key checks */
#define SAMPSTRING "%d S-Blaster Samples per Second "
#define STATSTRING "Avrg Dot:%d Avrg Dash:%d (* resets) "
static int code=0;
static int mask=1;
UINT sbstat;
char far *bufone=NULL; char far *bufin=NULL;
char far *buftwo=NULL; char far *bufdsp=NULL; char far *bi;
char far *bufone=NULL; char far *bufin=NULL;
char far *buftwo=NULL; char far *bufdsp=NULL; char far *bi;
static int done=FALSE;
static int done=FALSE;
int dspcount;
pokeb(VIDSEG,80+line+(maxlevel[l]<<1),0x07);
// The limit is a function of the
// calc limit
limit=flip+(5*average);
// The limit is a function of the
// calc limit
limit=flip+(5*average);
// Update the average display if this
// average signal is different than
// the last.
if (average != oldavg)
pokeb(VIDSEG, 2482+(oldavg<<1), 0x20);
pokeb(VIDSEG, 2482+(average<<1), 0xB3);
average = limit;
pokeb(VIDSEG, 2482+(average<<1), ((average==focavg)?(0xBA):(0xB3)));
pokeb(VIDSEG, 2482+(focavg<<1), ((average==focavg)?(0xBA):(0xB3)));
pokeb(VIDSEG, 2482+(oldlimit<<1), 0x20);
// The limit is a function of the
// calc limit
limit=flip+(5*average);
static int focAvg[M];
totFFT[0] = avgFFT[0][1];
totFFT[00] = avgFFT[0][00];
totFFT[00] -= avgFFT[0,00];
totFFT[00] -= avgFFT[0,00];
totFFT[01] -= avgFFT[0,01];
totFFT[02] -= avgFFT[0,02];
totFFT[03] -= avgFFT[0,03];
totFFT[04] -= avgFFT[0,04];
totFFT[05] -= avgFFT[0,05];
totFFT[06] -= avgFFT[0,06];
totFFT[07] -= avgFFT[0,07];
totFFT[08] -= avgFFT[0,08];
totFFT[09] -= avgFFT[0,09];
totFFT[10] -= avgFFT[0,10];
totFFT[11] -= avgFFT[0,11];
totFFT[12] -= avgFFT[0,12];
totFFT[13] -= avgFFT[0,13];
totFFT[14] -= avgFFT[0,14];
static char fft[N*MAXFFT]; // FFT buffer for smoothing
static char fft[N*MAXFFT]; // scaled FFT buffer for smoothing
totFFT[00] -= fft[0][00];
char cntFFT=1; // number of FFT thangs to track
totFFT[09] +=
avgFFT[00] =
) / cntFFT;
fft[0][00]
fft[0][00];
static char fft[MAXFFT][N]; // scaled FFT buffer for smoothing
static char fft[MAXFFT][N]; // scaled FFT buffer for smoothing
UINT totFFT[N-1]; // total of the smoothed FFT thang
char oldFFT[N-1]; // last smoothed FFT thing
char avgFFT[N-1]; // average FFT over cntFFT iterations
) / cntFFTp1;
123456789-123456789-123456789-12345678
1|oFreq: 12345 oSmooth: 333
2|oSkip: 12
static unsigned int sbSampleRate = SAMPLEMAX;
17 1|(QW) Freq: 12345 (ER) Smooth: 333
18 2|(AS) Skip: 12
clearGraph();
for (l=0,l160=0; l<(N-1); l++,l160+=160)
for (c=41; c<GRAPHTOP; c++)
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,l160+(c<<1),0xFA);
pokeb(VIDSEG,l160+(c<<1)+1,col);
memset(oldFFT, 0, sizeof(oldFFT));
memset(avgFFT, 0, sizeof(avgFFT));
notTotReset = TRUE;
// Clear the FFT results.
memset(fft, 0, sizeof(fft));
memset(totFFT, 0, sizeof(totFFT));
if (sbOver<0xFFFF) sbOver++;
updateDisplay();
avgFFT[freqm2]+
avgFFT[00]+
pokeb(VIDSEG, 2482+(focavg<<1), 0x20);
pokeb(VIDSEG, 2482+(oldfocavg<<1), 0x20);
pokeb(VIDSEG, 2482
pokeb(VIDSEG, 2482+(oldfocavg<<1), 0x20);
target = (totavg<<1) + offset;
pokeb(VIDSEG, 2482+(target<<1), 0x20);
totavg= max(avgFFT[ 0],avgFFT[ 1])
max(avgFFT[ 0],avgFFT[ 1])
thisCnt++;
static int focavg=4, oldfocavg=4;
static int totavg=4, oldtotavg=4;
static int target;
static ULONG totMark, cntMark;
static ULONG totSpace, cntMark;
static UINT thisLength=0;
static ULONG totMark, cntMark, avgMark; // mark statistics
static ULONG totSpace, cntSpace, avgSpace; // space statistics
static UINT thisLength=0; // current stats
// Copy the current average FFT
// values to a temporary buffer for
// erasing the display.
memcpy(oldFFT, avgFFT, sizeof(oldFFT));
// Subtract the oldest FFT result
// from the average total.
if (notTotReset)
totFFT[ 0] -= fft[0][ 0];
totFFT[ 1] -= fft[0][ 1];
totFFT[ 2] -= fft[0][ 2];
totFFT[ 3] -= fft[0][ 3];
totFFT[ 4] -= fft[0][ 4];
totFFT[ 5] -= fft[0][ 5];
totFFT[ 6] -= fft[0][ 6];
totFFT[ 7] -= fft[0][ 7];
totFFT[ 8] -= fft[0][ 8];
totFFT[ 9] -= fft[0][ 9];
totFFT[10] -= fft[0][10];
totFFT[11] -= fft[0][11];
totFFT[12] -= fft[0][12];
totFFT[13] -= fft[0][13];
totFFT[14] -= fft[0][14];
notTotReset = TRUE;
// Shift the FFT buffer left one
// graph, erasing the oldest FFT and
// making room for the new one.
memmove(&(fft[0][0]), &(fft[1][0]), N*(cntFFT-1));
// Calculate cntFFT minus 1 for speed
cntFFTm1 = cntFFT - 1;
// Fill in the resulting FFT array
// while adding the new values to the
// FFT total for "cntFFT" iterations.
// Also calculate the average FFT at
// this time.
avgFFT[ 0] =
totFFT[ 0] +=
fft[cntFFTm1][ 0] =
(abs(s1Mf25s3f27s5f29s7f31+s2Mf26Ps4f28s6f30Ms8f16)>>SCALE)+
(abs(s1Pf31s3f29s5f27s7f25+s2Pf30Ps4f28s6f26Ps8f24)>>SCALE)
) / cntFFT;
notSpaceReset = FALSE;
totSpace += (bufspace[cntBuf-1] = thisCnt);
totMark = cntMark = avgMark = 0;
totSpace = cntSpace = avgSpace = 0;
notMarkReset = FALSE;
notSpaceReset = FALSE;
notMarkReset = TRUE;
notSpaceReset = FALSE;
max
(
max
(
max(max(avgFFT[ 0],avgFFT[ 1]),max(avgFFT[ 2],avgFFT[ 3])),
max(max(avgFFT[ 4],avgFFT[ 5]),max(avgFFT[ 6],avgFFT[ 7]))
),
max
(
max(max(avgFFT[ 8],avgFFT[ 9]),max(avgFFT[10],avgFFT[11])),
max(max(avgFFT[12],avgFFT[14]),avgFFT[14])
)
)
max
(
avgFFT[freq],
max
(
max(avgFFT[freqm2],avgFFT[freqm1]),
max(avgFFT[freqp1],avgFFT[freqp2])
)
)
oldallavg = allavg;
oldtonedetected = tonedetected;
if (avgFFT[ 0]<offset) avgFFT[ 0] = 1;
avgFFT[ 1]+
alltot = avgFFT[ 0]+
avgFFT[ 1]+
avgFFT[ 2]+
avgFFT[ 3]+
avgFFT[ 4]+
avgFFT[ 5]+
avgFFT[ 6]+
avgFFT[ 7]+
avgFFT[ 8]+
avgFFT[ 9]+
avgFFT[10]+
avgFFT[11]+
avgFFT[12]+
avgFFT[13]+
avgFFT[14]
#define FLIP 5 /* levels above average sufficient to trigger tone detected */
#define LOG2N 4 /* Adjust according to N way above */
static int tonedetected=FALSE; /* indicates a tone is currently present */
static int freqm2,freqm1,freqp1,freqp2,freq=(N>>1); /* interesting frequency */
void FFT2tone(void)
{ /* determines whether a morse tone is present or not */
static int old3active,old2active=FALSE,old1active=FALSE,active=FALSE;
static int average,l,limit,oldtonedetected;
average=0;
for (l=1 ; l<N ; l++) average+=fft[l];
average>>=LOG2N;
limit=FLIP+(5*average);
old3active=old2active;
old2active=old1active;
old1active=active;
active=( (fft[freqm2]+fft[freqp2]+fft[freqm1]+fft[freqp1]+fft[freq])>=limit );
oldtonedetected=tonedetected;
tonedetected=(active || old1active || old2active || old3active);
if (tonedetected && !oldtonedetected) pokeb(videoseg,158,'
else if (oldtonedetected && !tonedetected) pokeb(videoseg,158,'
avgFFT[freqm1]+
avgFFT[ 0]+
pokeb(VIDSEG, 2482+(target<<1), 0x20);
avgFFT[ 0]+
avgFFT[ 1]+
avgFFT[ 2]+
avgFFT[ 3]+
avgFFT[ 4]+
avgFFT[ 5]+
avgFFT[ 6]+
avgFFT[ 7]+
avgFFT[ 8]+
avgFFT[ 9]+
avgFFT[10]+
avgFFT[11]+
avgFFT[12]+
avgFFT[13]+
avgFFT[14]
((morse==MORSE_MORSE)?("morse)."):((morse==MORSE_TEXT)?("text )."):("tone ).")))
enum MORSE_TYPES
MORSE_MORSE, MORSE_TEXT, MORSE_TONE, MORSE_MAX
push ax // save the registers we're using
push bx
push cx
push ds
push es
push di
push si
nosound();
freqp1 = freq + 1;
pokeb(VIDSEG,(74-160)+(160*freqm2),c1);
pokeb(VIDSEG,(74-160)+(160*freqm1),c1);
pokeb(VIDSEG,(74-160)+(160*freq),c1);
pokeb(VIDSEG,(74-160)+(160*freqp1),c1);
pokeb(VIDSEG,(74-160)+(160*freqp2),c1);
pokeb(VIDSEG,(76-160)+(160*freqm2),c2);
pokeb(VIDSEG,(76-160)+(160*freqm1),c2);
pokeb(VIDSEG,(76-160)+(160*freq),c2);
pokeb(VIDSEG,(76-160)+(160*freqp1),c2);
pokeb(VIDSEG,(76-160)+(160*freqp2),c2);
pokeb(VIDSEG,(74-160)+(160*freqm2),c1);
pokeb(VIDSEG,(74-160)+(160*freqm1),c1);
pokeb(VIDSEG,(74-160)+(160*freq),c1);
pokeb(VIDSEG,(74-160)+(160*freqp1),c1);
pokeb(VIDSEG,(74-160)+(160*freqp2),c1);
pokeb(VIDSEG,(74-160)+(160*outm1), c1);
// Clear the audio spectrum analyzer
// on the screen.
for (l=0,l160=0; l<(N-1); l++,l160+=160)
for (c=41; c<GRAPHTOP; c++)
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,l160+(c<<1),0xFA);
pokeb(VIDSEG,l160+(c<<1)+1,col);
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,l160+(c<<1),0xFA);
pokeb(VIDSEG,l160+(c<<1)+1,col);
pokeb(VIDSEG,(outm1*160)+(c<<1)+1,0x10);
pokeb(VIDSEG,(outm1*160)+(c<<1)+1,col);
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
// Tune out that graph portion.
for (c=41; c<GRAPHTOP; c++)
if (onoff)
col=16;
else
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,(outm1*160)+(c<<1)+1,col);
pokeb(VIDSEG,(out*160)+(c<<1)+1,col);
pokeb(VIDSEG,(outp1*160)+(c<<1)+1,col);
pokeb(VIDSEG,(outm1*160)+(c<<1)+1,col);
pokeb(VIDSEG,(out*160)+(c<<1)+1,col);
if (c<BLU) col=1; // 9
else if (c<GRN) col= 2; // 10
else if (c<YEL) col= 6; // 14
else col= 4; // 12
if (c<BLU) col=1; // 9
else if (c<GRN) col= 2; // 10
else if (c<YEL) col= 6; // 14
else col= 4; // 12
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
if (c<BLU) col=1; // 9
else if (c<GRN) col= 2; // 10
else if (c<YEL) col= 6; // 14
else col= 4; // 12
alltot= (
avgFFT[ 0]+
avgFFT[ 1]+
avgFFT[ 2]+
avgFFT[ 3]+
avgFFT[ 4]+
avgFFT[ 5]+
avgFFT[ 6]+
avgFFT[ 7]+
avgFFT[ 8]+
avgFFT[ 9]+
avgFFT[10]+
avgFFT[11]+
avgFFT[12]+
avgFFT[13]+
)
gotoxy(1,1); cprintf("%d %d ", freq, out);
/////////////////////////////////////////////////////////////////////////////
void updateCursors(char onoff)
char c1, c2;
int c, col;
// Determine the cursor characters.
if (onoff)
c1 = '<';
c2 = '>';
else
c1 = c2 = ' ';
// Calculate the focus cursor range.
freqm2 = freq - 2;
freqm1 = freq - 1;
freqp1 = freq + 1;
freqp2 = freq + 2;
// Calculate the tuned-out cursor.
outm1 = out - 1;
outp1 = out + 1;
// Display the tuned-out cursor.
pokeb(VIDSEG,(74)+(160*outm1), c1);
pokeb(VIDSEG,(74)+(160*out), c1);
pokeb(VIDSEG,(74)+(160*outp1), c1);
// Tune out that graph portion.
for (c=41; c<GRAPHTOP; c++)
if (tuneout && onoff)
col=8;
else
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
pokeb(VIDSEG,((outm1)*160)+(c<<1)+1,col);
pokeb(VIDSEG,((out)*160)+(c<<1)+1,col);
pokeb(VIDSEG,((outp1)*160)+(c<<1)+1,col);
// Display the frequency cursor.
pokeb(VIDSEG,(76)+(160*freqm2),c2);
pokeb(VIDSEG,(76)+(160*freqm1),c2);
pokeb(VIDSEG,(76)+(160*freq),c2);
pokeb(VIDSEG,(76)+(160*freqp1),c2);
pokeb(VIDSEG,(76)+(160*freqp2),c2);
// Focus on the graph bit.
for (c=41; c<GRAPHTOP; c++)
if (c<BLU) col=9;
else if (c<GRN) col=10;
else if (c<YEL) col=14;
else col=12;
if (onoff)
col |= 0x68;
pokeb(VIDSEG,((freqm2)*160)+(c<<1)+1,col);
pokeb(VIDSEG,((freqm1)*160)+(c<<1)+1,col);
pokeb(VIDSEG,((freq)*160)+(c<<1)+1,col);
pokeb(VIDSEG,((freqp1)*160)+(c<<1)+1,col);
pokeb(VIDSEG,((freqp2)*160)+(c<<1)+1,col);
asm {
push ax // save the registers we're using
push bx
push cx
push ds
push es
push di
push si
mov bx, 0x01 // line to scroll into
mov ax, VIDSEG // source and destionation segments
push ax
push ax
pop ds
pop es
lineloop:
asm {
mov ax, 0x00A0 // calculate offset of dest line
mul bl
inc ax
inc ax
mov di, ax
cmp bx, 0x17 // see if we're done
je scrolldone // leave the scroll if so
add ax, 0xA0 // calculate offset of source
mov si, ax
mov cx, 0x22 // number of WORDS to move
rep movsw // move them
inc bx // go to the next line
jmp lineloop // loop around to calculate it
scrolldone:
asm {
mov ax, 0x0720 // word to clear a display character
mov cx, 0x22 // number of words to erase
rep stosw
pop si // restore the registers we've saved
pop di
pop es
pop ds
pop cx
pop bx
pop ax
x=1;
#define BOXTOP 0x00 // 0-based line of box top
#define BOXDIV 0x0B // 0-based line of box divider
#define BOXBOT 0x17 // 0-based line of box bottom
pokeb(VIDSEG,(160*BOXTOP)+(BOXLEF<<1),0xDA);
morsePutC(0x20);
/////////////////////////////////////////////////////////////////////////////
// Put a character into the text window.
void textPutC(char c)
static int x=1, y=23;
pokeb(VIDSEG,(x<<1)+(y*160), c);
x++;
if (x>=35)
asm {
push ax // save the registers we're using
push bx
push cx
push dx
push ds
push es
push di
push si
// line to scroll into
mov bx, BOXTOP+1
// source and destination segments
mov ax, VIDSEG
push ax
push ax
pop ds
pop es
lineloop:
asm {
// calculate dest line offset
mov ax, 0x00A0
mul bl
// calculate the left window inside
mov dx, BOXLEF
inc dx
shl dx, 1
// combine them
add ax, dx
cmp bx, BOXDIV-1 // see if we're done
je scrolldone // leave the scroll if so
add ax, 0xA0 // calculate offset of source
mov si, ax
mov cx, 0x22 // number of WORDS to move
rep movsw // move them
inc bx // go to the next line
jmp lineloop // loop around to calculate it
scrolldone:
asm {
mov ax, 0x0720 // word to clear a display character
mov cx, 0x22 // number of words to erase
rep stosw
pop si // restore the registers we've saved
pop di
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
x=1;
pokeb(VIDSEG,(x<<1)+((BOXDIV-1)*160), c);
pokeb(VIDSEG,(x<<1)+((BOXBOT-1)*160), c);
if (thisCnt >= (useSpace*3))
{
textPutC(0x20);
}
morsePutC(0x20);
morsePutC('-');
morsePutC(0xF9);
// Update periodical display stuff.
updateDisplay();
// Show new sample rate
updateDisplay();
morsePutC(0x20);
morsePutC(0x20);
morsePutC(0x20);
/////////////////////////////////////////////////////////////////////////////
// Add a character to the tone line.
void tonePutC(char c)
// scroll the tone line (bottom) left
// add a character at the end of the line
asm {
// Save registers
push ax
push bx
push cx
push ds
push es
push di
push si
// source and destination segments
mov ax, VIDSEG
push ax
push ax
pop ds
pop es
// Dest & source offsets
mov di, 0x0F00
mov si, 0x0F02
// Set the move count (words)
mov cx, 0x004F
// Move the junk
rep movsw
// Restore registers
pop si
pop di
pop es
pop ds
pop cx
pop bx
pop ax
pokeb(VIDSEG, (160*25)-2, c);
/////////////////////////////////////////////////////////////////////////////
// Put a character into the text window.
void textPutC(char c)
static int x=BOXLEF+1;
pokeb(VIDSEG,(x<<1)+((BOXDIV-1)*160), c);
if ((++x)>=BOXRIG)
asm {
push ax // save the registers we're using
push bx
push cx
push dx
push ds
push es
push di
push si
// line to scroll into
mov bx, BOXTOP+1
// source and destination segments
mov ax, VIDSEG
push ax
push ax
pop ds
pop es
lineloop:
asm {
// calculate dest line offset
mov ax, 0x00A0
mul bl
// calculate the left window inside
mov dx, BOXLEF
inc dx
shl dx, 1
// combine them
add ax, dx
mov di, ax
cmp bx, BOXDIV-1 // see if we're done
je scrolldone // leave the scroll if so
add ax, 0xA0 // calculate offset of source
mov si, ax
mov cx,(BOXRIG-BOXLEF)-1
rep movsw // move them
inc bx // go to the next line
jmp lineloop // loop around to calculate it
scrolldone:
asm {
// AX = word to clear; CX = count
mov ax, 0x0720
mov cx, (BOXRIG-BOXLEF)-1
rep stosw // clear the last line in the window
pop si // restore the registers we've saved
pop di
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
x=BOXLEF+1;
/////////////////////////////////////////////////////////////////////////////
// Put a character into the morse window.
void morsePutC(char c)
static int x=BOXLEF+1;
pokeb(VIDSEG,(x<<1)+((BOXBOT-1)*160), c);
if ((++x)>=BOXRIG)
asm {
push ax // save the registers we're using
push bx
push cx
push dx
push ds
push es
push di
push si
// line to scroll into
mov bx, BOXDIV+1
// source and destination segments
mov ax, VIDSEG
push ax
push ax
pop ds
pop es
lineloop:
asm {
// calculate dest line offset
mov ax, 0x00A0
mul bl
// calculate the left window inside
mov dx, BOXLEF
inc dx
shl dx, 1
// combine them
add ax, dx
mov di, ax
cmp bx, BOXBOT-1 // see if we're done
je scrolldone // leave the scroll if so
add ax, 0xA0 // calculate offset of source
mov si, ax
// word count to move
mov cx, (BOXRIG-BOXLEF)-1
rep movsw // move them
inc bx // go to the next line
jmp lineloop // loop around to calculate it
scrolldone:
asm {
// AX = clear word; CX = word count
mov ax, 0x0720
mov cx, (BOXRIG-BOXLEF)-1
rep stosw
pop si // restore the registers we've saved
pop di
pop es
pop ds
pop dx
pop cx
pop bx
pop ax
x=(BOXLEF+1);
pokeb(VIDSEG, 158, 0xEC);
// Display a character in the "tone" display across the screen bottom.
void tonePutC(char c)
// scroll the tone line (bottom) left
// add a character at the end of the line
asm {
// Save registers
push ax
push bx
push cx
push ds
push es
push di
push si
// source and destination segments
mov ax, VIDSEG
push ax
push ax
pop ds
pop es
// Dest & source offsets
mov di, 0x0F00
mov si, 0x0F02
// Set the move count (words)
mov cx, 0x004F
// Move the junk
rep movsw
// Restore registers
pop si
pop di
pop es
pop ds
pop cx
pop bx
pop ax
pokeb(VIDSEG, (160*25)-2, c);
if (useSpace>1)
{
useSpace--;
updateDisplay();
}
break;
if (useSpace>100)
{
useSpace -= 100;
updateDisplay();
}
break;
if (useSpace<2000)
{
useSpace++;
updateDisplay();
}
break;
if (useSpace<9999)
{
useSpace++;
updateDisplay();
}
break;
if (thrNoise>1)
{
thrNoise--;
updateDisplay();
}
break;
if (thrNoise<9999)
{
thrNoise++;
updateDisplay();
}
break;
if (useMark>1)
{
useMark--;
updateDisplay();
}
break;
if (useMark<9999)
{
useMark++;
updateDisplay();
}
break;
f[k]=(*(dsp+=waitfactor))-128;
f[k]=(*(dsp+=waitfactor))-128;
f[ k]=(*(dsp+=waitfactor))-128;
memmove(bufSpace, bufSpace+1, cntBuf-1);
avgSpace = (totSpace += (bufSpace[cntBuf-1] = thisCnt))/cntBuf;